package com.lp.wxpay;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

import com.lp.wxpay.sdk.IWXPayDomain;
import com.lp.wxpay.sdk.WXPayConfig;

public class MyConfig extends WXPayConfig{

    private byte[] certData;

    public MyConfig() throws Exception {
        String certPath = "C:\\Users\\DELL\\Desktop\\cert\\apiclient_cert.p12";
        File file = new File(certPath);
        InputStream certStream = new FileInputStream(file);
        this.certData = new byte[(int) file.length()];
        certStream.read(this.certData);
        certStream.close();
    }

    public String getAppID() {
        return "wx1f01eabc3968e9d6";
    }

    public String getMchID() {
        return "1234722402";
    }

    public String getKey() {
        return "t6mKuqO3IDll1eMY6tpo0HnsmxTy4fNi";
    }

    public InputStream getCertStream() {
        ByteArrayInputStream certBis = new ByteArrayInputStream(this.certData);
        return certBis;
    }

    public int getHttpConnectTimeoutMs() {
        return 8000;
    }
    /**
     * 获取WXPayDomain, 用于多域名容灾自动切换
     * @return
     */
    public IWXPayDomain getWXPayDomain(){
		return new IWXPayDomain() {
			
			@Override
			public void report(String domain, long elapsedTimeMillis, Exception ex) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public DomainInfo getDomain(WXPayConfig config) {
				// TODO Auto-generated method stub
				return new DomainInfo("api.mch.weixin.qq.com", true);
			}
		};
    	
    }
    public int getHttpReadTimeoutMs() {
        return 10000;
    }
}
